package org.mm.frame.format;

import java.text.ParseException;
import java.util.Locale;

import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormatter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.format.Formatter;

public class PersonalDateTimeFormatter implements Formatter<DateTime> {

	final Logger log = LoggerFactory.getLogger(PersonalDateTimeFormatter.class);
	
	DateTimeFormatter dateFormat = null;
	
	public PersonalDateTimeFormatter(DateTimeFormatter dateFormat) {
		this.dateFormat = dateFormat;
	}

	public String print(DateTime dateTime, Locale locale) {
		log.info("Formatting datetime1: " + dateTime + "-locale: " + locale);
		return dateFormat.print(dateTime);
	}

	public DateTime parse(String dateTimeString, Locale locale)
			throws ParseException {
		log.info("Parsing date string1: " + dateTimeString + "-locale: " + locale);
		return dateFormat.parseDateTime(dateTimeString);
	}

}
